$(document).ready(function(){
	cw.common.setStyle();
	//$('#subImg').bind('click',subButton);
	//cw.common.getUserSession(loadRoleTree,true);
	
	//初始化年份
	var myDate=new Date();
	$('#CREATE_DATE_BEGIN').val(myDate.getFullYear().toString());
	
	getReportList();
	
})
var ROWS_COUNT = 0;
function getReportList(){
	ROWS_COUNT = 0;
	var url = cw.common.path + '/json?action=QUERY_T_FIXED_ASSETSBY_PAGER_FOR_REPORT_ACTION';
	url += "&CREATE_DATE_BEGIN="+$('#CREATE_DATE_BEGIN').val()+"&CREATE_DATE_END="+$('#CREATE_DATE_BEGIN').val()+"&IS_VALID=0&IS_YEAR=1";
	var xmlname = "T_FIXED_ASSETS";
	var pagePanel='#pager';
	var result='#list';
	var pageSize=10;
	var defaultHtml='<li><em style="text-align: center;width:100%">没有搜索到您要查询的数据...</em></li>';
	cw.common.changePage(url,pageSize,xmlname,result,fn_getUserList,pagePanel,defaultHtml);
}
function fn_getUserList(obj,result,i){
	ROWS_COUNT = 1;
	var str = "<li>";
	str += "<em style='width: 9%; text-align: center;'>"+obj.BARCODE+"</em>";
	str += "<em style='width: 9%; text-align: center;''>"+obj.FIXED_ASSETS_NAME+"</em>";
	str += "<em style='width: 9%; text-align: center;''>"+obj.WITH_MANANGER+"</em>";
	str += "<em style='width: 9%; text-align: center;'>"+obj.STORED_IN+"</em>";
	str += "<em style='width: 9%; text-align: center;'>"+cw.common.toChar(obj.STOCK_DATE,'yyyy-mm-dd')+"</em>";
	str += "<em style='width: 9%; text-align: center;'>"+obj.USE_YEAR+"</em>";
	str += "<em style='width: 9%; text-align: center;'>"+obj.WARRANTY+"</em>";
	str += "<em style='width: 9%; text-align: center;'>"+obj.SPECIFICATION+"</em>";
	str += "<em style='width: 9%; text-align: center;'>"+obj.SUPPLIERS_NO+"</em>";
	str += "<em style='width: 9%; text-align: center;'>"+obj.FACTORY_NO+"</em>";
	str += "</em></li>";
	$(result).append(str);
}

//删除用户
function exportReportList(){
	if(ROWS_COUNT==0){
		alert("导出的结果集不可以为空！");
		return false;
	}
	
	var xmlname = "T_FIXED_ASSETS";
	var url = cw.common.path + '/json?action=QUERY_T_FIXED_ASSETSBY_PAGER_FOR_REPORT_ACTION';
		url += "&CREATE_DATE_BEGIN="+$('#CREATE_DATE_BEGIN').val()+"&CREATE_DATE_END="+$('#CREATE_DATE_BEGIN').val()+"&IS_VALID=0&IS_YEAR=1&IS_EXPORT=1";
		
	$.post(url,{},function(data){
		if(data.success){
			location.href = "download.jsp?fileName=year_decrease_report.xls&realExportPath="+data.root.T_FIXED_ASSETS.rs;
			
		} else {
			alert(data.errors.errmsg);
		}
	},'json');
}